#include "packagemanager.hpp"

namespace PackageManager
{
	void login(QStringList args, Client* cl)
	{
		int state = args[0].toInt();
		if (state == 0)
			cl->emitAuthentificationFail();
		else if (state == -1)
			cl->emitAuthentificationDouble();
		else
			cl->emitAuthentificationOK();
	}


	void ecg(QStringList list, QSslSocket* socket)
	{
		QFile ecgFile("ecg.txt");

	       // Wait for answer
	       ecgFile.open(QIODevice::ReadWrite | QIODevice::Text);

	       // Test
	       QTextStream stream(&ecgFile);

	       stream << list[0];

	       while(socket->bytesAvailable())
	       {
		       // Read the server Answer line by line
		       QString answerLine = socket->readLine();
		       QStringList package;
		       package = answerLine.split(":");
		       stream << package[1];
	       }

	       ecgFile.close();

	}

}
